In the first program we have a new function which is called, with a depressing lack of imagination on my part, func2. This is a void function (in that it returns nothing) but it accepts a single parameter .
Parameters are kind of fun. They look like variables in the function body, but they are set with the value given to then when they are called. In the function above we have a parameter which is called in. When the function is entered we notice that a new storage location appears (which is coloured red). This has been set with the value of the parameter when the function was called. In this case count has the value 100, so in is set to the value 100.
Like local variables, parameters vanish when the function block is exited. Note that I have used the return keyword to explicitly tell C that I want to return from the function. If your function is void you do not need to use this, but it makes the function clearer. If the function is void you should not try to return a value, the compiler will notice this and give you an error message.
Now look at the second VPIC
This shows you how parameters have different values depending on what they are supplied with when the function is called. The first time we call func2 the variable count has the value 100, so the parameter in has that value as well. The second time we call it we have made the value of count 101, so when the function runs the parameter in is also set to 101.
You can do things like change the value of the parameter inside a function but this does not change the value of the variable in the calling program. This is very important. What I am saying is that if you change the value of in, this does not change the value of count. Some programming languages are not like this, what we are seeing is particular to C. In C you can only pass parameter values into functions. The only way you can get values out of a function is to use the value it returns or to use pointers.
Finally, look at the third VPIC.
When the value of in is changed in func2 the value of count is not. This is what we would expect.
You can feed things into functions to tell them how to do things for you. Some examples you might want to write are:
void delay ( char size )
/* delay for a time */ void flash ( char count )
/* flash a LED a number of times */